123456789101112131415161718192021 |
- #include <stdio.h>
- int main() {
- int a, b, sum = 0;
- scanf("%d %d",&a,&b);
-
- int c;
- for(c = a; c <= b; c++) {
- int i, is = 1;
- for(i = 2; i < c; i++) {
- if(c % i == 0) {
- is = 0;
- break;
- }
- }
- if(is == 1) sum += c;
- }
- printf("%d-%d之间的素数和为%d",a,b,sum);
-
- return 0;
- }
|